#include<stdio.h>
#include<math.h>
int main()
{
	int i = 0;
	for (i = 1; i <= 100000; i++)
	{
		int count = 0;
		int k = i;
		while (k != 0)
		{
			count++;
			k /= 10;
		}
		int a = count;
		int num = 0;
		k = i;
		while (a--)
		{
			int j =k% 10;
			num += pow(j, count);
			k = k / 10;
		}
		if (i == num)
			printf("%d ", i);
 	}
	return 0;
}